<?php

namespace app\admin\model\shopro;

use think\Model;


class Tradeorderaudit extends Model
{

    

    

    // 表名
    protected $name = 'shopro_trade_order_audit';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text',
        'status_text',
        'platform_text'
    ];
    

    
    public function getTypeList()
    {
        return ['recharge' => __('Type recharge')];
    }

    public function getStatusList()
    {
        return ['-1' => __('Status -1'), '0' => __('Status 0'), '1' => __('Status 1')];
    }

    public function getMethodsList()
    {
        return ['alipay' => __('Methods alipay'), 'wechat' => __('Methods wechat'), 'usdt' => __('Methods usdt'),'bankcard' => __('Methods bankcard')];
    }

    public function getPlatformList()
    {
        return ['H5' => __('Platform h5'), 'WechatOfficialAccount' => __('Platform wechatofficialaccount'), 'WechatMiniProgram' => __('Platform wechatminiprogram'), 'App' => __('Platform app')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPlatformTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['platform']) ? $data['platform'] : '');
        $list = $this->getPlatformList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
